;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; This file is part of ICCLE2.
;
; ICCLE2 is free software: you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation, either version 3 of the License, or
; (at your option) any later version.
;
; ICCLE2 is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with ICCLE2.  If not, see <http://www.gnu.org/licenses/>.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defun bore (l &optional (best 0.2))
  (let (best-num)
    (labels ((best ()
               (let* ((nums  (mapcar #'(lambda(l) (last1 l)) l))
                      (sorted (sort nums #'<))
                      (best2   (if (< best 0) (* -1 best) (- 1  best)))
                      (best-pos  (round (* (length sorted) best2))))
                 (nth best-pos sorted)))
             (class (x)  
               (if (< best 0)
                   (if (<= x best-num) 'best 'rest)
                   (if (>= x best-num) 'best 'rest))))
      (setf best-num (best))
      (mapcar #'(lambda (l1)
                  (setf (last1 l1) (class (last1 l1)))) 
              l)
      l)))
